package com.ltkj.shop.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ltkj.common.core.utils.bean.BeanUtils;
import com.ltkj.shop.domain.ShopGoods;
import com.ltkj.shop.domain.ShopStore;
import com.ltkj.system.api.domain.ShopGoodsDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.compress.utils.Lists;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 文创商品页面展示对象 shop_goods
 * 
 * @author xupf
 * @date 2023-08-31
 */
@ApiModel(value = "文创商品页面展示类")
@Data
public class ShopGoodsVo extends ShopGoods
{
    private static final long serialVersionUID = 1L;

    /** 上下架时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("上下架时间")
    private Date onOffTime;

    /** 商品规格 */
    @ApiModelProperty(value = "商品规格")
    private Map<String, List<ShopGoodsSpecVo>> goodsSpecs;


    /** 商品轮播图 */
    @ApiModelProperty(value = "商品轮播图")
    private List<ShopImgVo> imgDetails = Lists.newArrayList();


    /** 商店信息 */
    @ApiModelProperty(value = "商店信息")
    private ShopStore shopStore;


    /** 缩略图类型（移动端首页使用） */
    @ApiModelProperty(value = "缩略图类型")
    private String fileType = "0";

    /** 缩略图地址（移动端首页使用） */
    @ApiModelProperty(value = "缩略图地址")
    private String imgPath;

    /** 移动端首页使用 */
    @ApiModelProperty(value = "title")
    private String title;

    /** 移动端首页使用 */
    @ApiModelProperty(value = "tabType")
    private String tabType = "3";

    public String getTitle() {
        return getName();
    }

    public String getImgPath() {
        return getImgAbbrev();
    }

    public static ShopGoodsDTO toShopGoodsDTO(ShopGoodsVo vo) {
        ShopGoodsDTO shopGoodsDTO = new ShopGoodsDTO();
        BeanUtils.copyBeanProp(shopGoodsDTO, vo);
        return shopGoodsDTO;
    }
}
